<?php
include_once '../info_struct.php';
include_once '../LDB_API/output.php';

/*
 * Usage:
 * ref_tooltip(ref_id);
 * Parameter:
 * ref_id - ID for which a tooltip shall be created
 * Return:
 * Returns no value but creates HTML-Code that displays an Reference
 * in the form [id]. If you put your mouse over [id] a tooltip with further
 * information (title, author, year) will appear.
 */
function ref_tooltip($ref_id) {
    /* Get infos object containing the reference with ref_id */
    $ref = ldb_get_by_id($ref_id);
    if ($ref) {
        /* Generate tooltip text from infos object */
        $tooltip = "$ref->title \n $ref->author \n $ref->year";
    } else {
        /* If the id is not in the database */
        $tooltip = "Reference not found.";
    }
    /* Print HTML-code for the tooltip */
    echo "<a title='$tooltip'>[$ref_id]</a>";
}